home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 7153 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.5 KB

  1. Path: linus.mitre.org!spectre!eachus
  2. From: eachus@spectre.mitre.org (Robert I. Eachus)
  3. Newsgroups: comp.lang.ada,comp.lang.c,comp.lang.c++
  4. Subject: Re: C/C++ knocks the ....
  5. Date: 19 Feb 1996 19:32:18 GMT
  6. Organization: The Mitre Corp., Bedford, MA.
  7. Message-ID: <EACHUS.96Feb19143218@spectre.mitre.org>
  8. References: <00001a73+00002504@msn.com> <4etcmm$lpd@nova.dimensional.com>
  9.     <3114d8fb.5a455349@zesi.ruhr.de> <4f5h5t$f13@vixen.cso.uiuc.edu>
  10.     <4g1bgf$l5@mailhub.scitec.com.au> <3124B43F.19E0@escmail.orl.mmc.com>
  11.     <4g2r2r$ded@stc06.ctd.ornl.gov> <dewar.824581148@schonberg>
  12.     <4g6hg8$f4j@ux1.lmu.edu>
  13. NNTP-Posting-Host: spectre.mitre.org
  14. In-reply-to: Ray Toal's message of 18 Feb 1996 06:38:00 GMT
  15.  
  16. In article <4g6hg8$f4j@ux1.lmu.edu> Ray Toal <rtoal@eecs.lmu.edu> writes:
  17.  
  18.   > Norman Cohen just posted a really good article on this topic a few
  19.   > days ago and I won't repeat it here.  It should at least "convince"
  20.   > people that separating package and type is a solid design decision
  21.   > and not a hack to maintain upward compatibility with Ada 83.
  22.  
  23.   > Having programmed in Smalltalk and C++ before Ada 95, I admit I had
  24.   > to look twice at the Ada approach because I was so USED TO confusing
  25.   > class with module.  But taking a few minutes to get used to Ada's
  26.   > approach I like it better.
  27.  
  28.     There are many people who start out with a "dogmatic" approach to
  29. ADTs in Ada, limiting them to one per package.  But after a while you
  30. ask why this type and that type appear in the same package
  31. specification, you get some mumbling about "the $%^*&* language makes
  32. it too difficult to put them in different packages."  A few months
  33. later you see cogent comments for ADTs in the same package explaining
  34. why it was done that way, and lots of what I prefer to call "helper"
  35. type declarations that have no explanation.  (And don't need any.)
  36.  
  37.     For example, assume that your (private) ADT has several associated
  38. flags.  You can (and often should) have one inquiry function for each
  39. flag.  But the boolean flags may really indicate that the ADT is in
  40. one of, say, five states.  Best in that case is to define an
  41. enumeration type in the same package and have a single inquiry
  42. function, and a single procedure to set the state if that is
  43. appropriate.
  44.  
  45.     Other cases where "helper" types appear is when there are arrays,
  46. lists, names, etc. as properties of the main ADT and the ONLY use of
  47. these types is as state of the primary ADT.
  48.  
  49. --
  50.  
  51.                     Robert I. Eachus
  52.  
  53. with Standard_Disclaimer;
  54. use  Standard_Disclaimer;
  55. function Message (Text: in Clever_Ideas) return Better_Ideas is...
  56.